using System.Data;
using System.Web.UI.WebControls;

using Framework.Library.Components.Providers;
using Framework.Library.Utilities;

namespace Framework.Library.Components.Lang
{
	public class MainLanguagesController
	{
		public static DataTable GetAll()
		{
            const string key = "Framework.Portal.MainLanguages.GetAll";
            DataCaching data = new DataCaching();
            DataTable dtLang = (DataTable)data.GetCache(key);
            if (dtLang != null) return dtLang;
            dtLang = DataAccessProvider.Instance().GetAll();
            data.InsertCacheNoExpireTime(key, dtLang);
            return dtLang;
		}
        public static DataTable GetAll_Without_Current_Language(string lang)
        {
            const string key = "Framework.Portal.MainLanguages.GetAll_Without_Current_Language";
            DataCaching data = new DataCaching();
            DataTable dtLang = (DataTable)data.GetCache(key);
            if (dtLang != null) return dtLang;
            dtLang = DataAccessProvider.Instance().GetAll_Without_Current_Language(lang);
            data.InsertCacheNoExpireTime(key, dtLang);
            return dtLang;
        }
        public static void LoadLanguage(ListItemCollection lstItems)
        {
            DataTable dtLanguage = GetAll();
            foreach (DataRow row in dtLanguage.Rows)
            {
                ListItem item = new ListItem(row["Language_Name"].ToString(), row["ID"].ToString());                
                lstItems.Add(item);
            }
        }
	}
}
